package br.figmania.conectation;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

/**
 * Hibernate Utility class with a convenient method to get Session Factory object.
 *
 * @author Vilmar Santos
 */
public class HibernateUtility {

	private static SessionFactory factory;

	static {
		try {
			factory = new AnnotationConfiguration().configure().buildSessionFactory();
		} catch (Exception e) {
			e.printStackTrace();
			factory = null;
		}
	}

	public static Session getSession() {
		return factory.openSession();
	}

}